package com.wj.rpsm.admin.pojo.user;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.UUID;

/**
 * @author WeiJin
 * @version 1.0
 */
@Data
@ApiModel("用户信息，包含管理员、物业人员和住户")
public class User extends LoginUser {
    @ApiModelProperty("用户id")
    private Integer userid;
    @ApiModelProperty("用户性别")
    private Short gender;
    @ApiModelProperty("用户年龄")
    private Short age;
    @ApiModelProperty("用户状态")
    private Short user_status;
    @ApiModelProperty("用户所属房屋id")
    private Short user_roomid;
    @ApiModelProperty("身份证号")
    private String idcard;
    @ApiModelProperty("用户头像路径")
    private String user_avatar;


    public static User toUser(LoginUser user) {
        User u = new User();
        u.setAccount(user.getAccount());
        u.setToken(user.getToken());
        u.setPassword(user.getPassword());
        u.setUsername(user.getUsername());
        u.setUser_type(user.getUser_type());
        return u;
    }

    public ResUser toResUser() {
        ResUser u = new ResUser();
        u.setAccount(this.getAccount());
        u.setUsername(this.getUsername());
        u.setUser_type(this.getUser_type());
        u.setToken(UUID.randomUUID().toString());
        return u;
    }
}
